package com.example.yls.demoa;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView textView;
    private ImageView dogImg;
    private Button btn;
    private  int[] dogs = {R.drawable.dog1,R.drawable.dog2,R.drawable.dog3,R.drawable.dog4,R.drawable.dog5};
    private int index = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
                textView = findViewById(R.id.txt1);
                textView.setText(R.string.niceToMeetingYou);

                textView.setTextColor(Color.GREEN);

                dogImg = findViewById(R.id.dI);
                btn = findViewById(R.id.btn);

                btn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dogImg.setImageResource(dogs[index]);
                        index=(index+1)%5;
                    }

                });
                }
                }
